import java.util.Arrays;

public class CopingArrays {

	public static void main(String[] args) {

		String[] oldArray = { "Will", "I", "be", "copied", "?" };

		int newLength = oldArray.length;

		// Before Java 6
		String[] newArray = new String[newLength];
		System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
		System.out.println(Arrays.toString(newArray));

		// After Java 6
		String[] copiedArray = Arrays.copyOf(oldArray, newLength);
		System.out.println(Arrays.toString(copiedArray));

		String[] longerCopy = Arrays.copyOf(oldArray, newLength + 5);
		System.out.println(Arrays.toString(longerCopy));

		String[] shorterCopy = Arrays.copyOf(oldArray, newLength - 2);
		System.out.println(Arrays.toString(shorterCopy));

		String[] rangeCopy = Arrays.copyOfRange(oldArray, 1, 3);
		System.out.println(Arrays.toString(rangeCopy));
	}
}
